class RatingQuestionsController < ApplicationController
  # GET /rating_questions
  # GET /rating_questions.json
  def index
    @rating_questions = RatingQuestion.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @rating_questions }
    end
  end

  # GET /rating_questions/1
  # GET /rating_questions/1.json
  def show
    @rating_question = RatingQuestion.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @rating_question }
    end
  end

  # GET /rating_questions/new
  # GET /rating_questions/new.json
  def new
    @rating_question = RatingQuestion.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @rating_question }
    end
  end


  # GET /rating_questions/1/edit
  def edit
    @rating_question = RatingQuestion.find(params[:id])
  end

  # POST /rating_questions
  # POST /rating_questions.json
  def create
    @rating_question = RatingQuestion.new(params[:rating_question])

    respond_to do |format|
      if @rating_question.save
        format.html { redirect_to @rating_question, notice: 'Rating question was successfully created.' }
        format.json { render json: @rating_question, status: :created, location: @rating_question }
      else
        format.html { render action: "new" }
        format.json { render json: @rating_question.errors, status: :unprocessable_entity }
      end
    end
  end

#def create
# rating_questions = []
# @ratingquestionlist = params[:rating_question]
#
# @ratingquestionlist.each do |r|
# rating_question = RatingQuestion.new(r)
# rating_questions << rating_question 
# end
#
# RatingQuestion.import(rating_question)
#
# render :json => { :status => :ok, :message => "RatingQuestion(s) Created Successfully"}
# 
#end



  # PUT /rating_questions/1
  # PUT /rating_questions/1.json
  def update
    @rating_question = RatingQuestion.find(params[:id])

    respond_to do |format|
      if @rating_question.update_attributes(params[:rating_question])
        format.html { redirect_to @rating_question, notice: 'Rating question was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @rating_question.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /rating_questions/1
  # DELETE /rating_questions/1.json
  def destroy
    @rating_question = RatingQuestion.find(params[:id])
    @rating_question.destroy

    respond_to do |format|
      format.html { redirect_to rating_questions_url }
      format.json { head :no_content }
    end
  end
end
